import 'dart:ui';

import 'package:flutter/services.dart';
import 'package:flutter_module/map/models/ni_geopoint_model.dart';
import 'package:flutter_module/map/ni_types.dart';
import 'package:flutter_module/system/library_map.dart';

import 'ni_map_method_id.dart';

class NIViewportDispatcher {
  ///设置地图中心点偏移
  ///地图中心偏移量[-1.0,1.0]之间
  Future setMapViewCenter(
      MethodChannel mapChannel, num xPivot, num yPivot) async {
    await mapChannel.invokeMethod(
        NIViewportMethodId.kMapViewportSetViewCenterMethod,
        {"xPivot": xPivot, "yPivot": yPivot});
  }

  ///获取几何的外接矩形,返回矩形的左上，右下两个坐标
  ///wkt格式的矩形
  Future<String> getBoundingBoxWkt(MethodChannel mapChannel, NIGeoPoint geoPoint,
      {SnapType snapType = SnapType.SNAP_PIXEL, int distance = 50}) async {
    var map = geoPoint.toMap();
    map.putIfAbsent("snapType", () => snapType.index);
    map.putIfAbsent("distance", () => distance);
    return await mapChannel.invokeMethod(
        NIViewportMethodId.kMapViewportGetBoundingBox, map);
  }
}
